
import { createRouter, createWebHashHistory } from "vue-router";
import Search from "../views/Search.vue";
import Topic from "../views/Topic.vue";
import Mine from "../views/Mine.vue";
import Layout from "../views/Layout.vue";
import Home from "../views/Home.vue";

const router = createRouter({
    linkActiveClass:'active',
    history: createWebHashHistory(),
    routes: [
        {
            path: '/layout', component: Layout, children: [
                { path: '/', redirect: '/home', meta: { title: '首页', name: 'home' } },
                { path: '/home', component: Home, meta: { title: '首页', name: 'home' }, },
                { path: '/topic', component: Topic, meta: { title: '榜单', name: 'topic' }, },
                { path: '/search', component: Search, meta: { title: '搜索', name: 'search' } },
                { path: '/mine', component: Mine, meta: { title: '我的', name: 'mine' } },
            ]
        },

    ]
})
router.beforeEach((to, from, next) => {
    document.title = to.meta.title;
    next();
})
export default router